package za.org.jcicada.genss.messages;

import java.io.Serializable;

/**
 * Result class for recording the status of a request in the reply. Where the
 * request was not successful there is a descriptive message.
 * @author rcrida
 */
public class Result implements Serializable {
    
    /** Serial version ID */
    private static final long serialVersionUID = 1L;

    /**
     * Encodes the success status of the request
     */
    private SuccessCode code;
    
    /**
     * Stores a descriptive message.
     */
    private String message;
    
    /**
     * Default constructor for success case with no message.
     */
    public Result() {
        this.code = SuccessCode.COMPLETE_SUCCESS;
        this.message = "";
    }
    
    /**
     * Construct result object with specified code and message
     * @param code the success status code
     * @param message descriptive message
     */
    public Result(SuccessCode code, String message) {
        this.code = code;
        this.message = message;
    }
    
    public SuccessCode getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }
    
    public String toString() {
    	return String.format("{%s - %s}", code.toString(), message);
    }

}
